﻿--添加分组名称和是否为默认
ALTER TABLE dbo.ReportFieldSettings ADD
	Name varchar(255) NULL,
	CreateTime datetime NULL,
	UpdateTime datetime NULL,
	IsEnable bit NULL,
	IsDefault bit NULL
GO
 

 CREATE TABLE dbo.UserBusinessPermissions
	(
	ID bigint NOT NULL IDENTITY (1, 1),
	UserID uniqueidentifier NULL,
	DEPTCode nvarchar(8) NULL
	)  ON [PRIMARY]
GO


ALTER TABLE FormCDB   DROP COLUMN BusinessType;

alter table FormCDB add financiaAmount [decimal](18, 2) null;

alter table FormCDB add isAgree [varchar](50) NULL;

alter table FormCDB add CommissionApr [decimal](18, 2) null;

ALTER TABLE FormCDB   DROP COLUMN Salesman;
alter table FormCDB add Salesman [uniqueidentifier]  null;

alter table FormCDB add GuaranteeType varchar(50)  null;

update FormCDB  set  GuaranteeType = '一般案件';



ALTER TABLE dbo.UserBusinessPermissions ADD
	DeptName nvarchar(50) NULL
GO
 ----2017-10-29



  ----2017-11-04

---  添加角色  担保用印管理员
---  添加角色  担保财务收款
---  添加角色  担保财务确认
--- 给财务添加添加权限 财务收款
--- 给综合室添加权限 综合室管理

 alter table FormCDB add PropertyClues varchar(505)  null;


 alter table FormCDB add HeadID uniqueidentifier null;
alter table FormCDB add HeadApr [decimal](18, 2) DEFAULT 0.00;


alter table FormCDB add RoleAID uniqueidentifier null;
alter table FormCDB add RoleAApr [decimal](18, 2) DEFAULT 0.00;


alter table FormCDB add RoleBID uniqueidentifier null;
alter table FormCDB add RoleBApr [decimal](18, 2) DEFAULT 0.00;

-- 会计备注
 alter table FormCDB add AccountRemark varchar(505)  null;



 --  陈湘林 2017-11-18 17:54:28添加

	
	alter table FormCDB add [CompanyName] [varchar](100) NULL;
	alter table FormCDB add [Bank] [varchar](100) NULL;
	alter table FormCDB add [AccountNo] [varchar](50) NULL;
	alter table FormCDB add [ContactName] [varchar](50) NULL;
	alter table FormCDB add [ContactTpey] [varchar](100) NULL;
	alter table FormCDB add [Due] [decimal](18, 0) NULL;
	alter table FormCDB add [PayCompany] [varchar](50) NULL;
	alter table FormCDB add [Remark] [varchar](500) NULL;
	
	alter table FormCDB add Taxation  [decimal](18, 0) NULL;  

	alter table FormCDB add InvoiceType  smallint NULL;
	
	alter table FormCDB add PaidAmount  [decimal](18, 0) NULL;
	
	
	update FormCDB set InvoiceType = 0 where IsInvoice = 0;
	
	update FormCDB set InvoiceType = 1 where IsInvoice = 1;
	
	update FormCDB set Taxation = 0 where IsInvoice = 0;
	
	update FormCDB set Taxation = PayableAmount * 0.1 where IsInvoice = 1;
	
	update FormCDB set PaidAmount = PayableAmount  where IsInvoice = 0;
	
	update FormCDB set PaidAmount = PayableAmount * 0.9 where IsInvoice = 1;
	
	ALTER TABLE FormCDB DROP COLUMN IsInvoice;  
	ALTER TABLE FormCDB DROP COLUMN ChargingMonth;
	ALTER TABLE FormCDB DROP COLUMN IsCreatGuarantee;
	
 
	ALTER TABLE FormCDB DROP COLUMN ReceivableTime;
	
	ALTER TABLE FormCDB DROP COLUMN CreatPactTime;

	INSERT [dbo].[WfProcess] ([ProcessGUID], [ProcessName], [PageUrl], [XmlFileName], [XmlFilePath], [Description], [CreatedDateTime], [LastUpdatedDateTime], [WfProcessTypeID], [Status], [Remark]) VALUES (N'81e31d18-bb62-43ce-b678-6143d79a72e5', N'联保保证金流程表', N'Form/FormNoContractPay', N'联保保证金流程.xml', N'1003', NULL, CAST(0x0000A56B00C69B6B AS DateTime), CAST(0x0000A56B00C69B6B AS DateTime), 1003, 1, NULL);

    update [WfProcess] set ProcessName = '诉讼业务申请表' where ProcessName = '担保业务流程表';


   update [WfProcess] set Status =  0 where ProcessName = '担保业务返佣表';

   -- 2017-11-22 23:07:33 陈湘林添加
   -- 是否盖章
 alter table FormCDB add SealStatus varchar(100)  null;
 
 -- 合作的联保公司名称：
  alter table FormCDB add LBgongsi varchar(100)  null;
  -- 担保标的金额
  alter table FormCDB add DBjine [decimal](18, 2) NULL;
    -- 协议费用
  alter table FormCDB add XYfeiyong [decimal](18, 2) NULL;
  -- 他司担保金额
  alter table FormCDB add TSDBjine [decimal](18, 2) NULL;
  -- 他司协议费用
  alter table FormCDB add TSXYfeiyong [decimal](18, 2) NULL;
  -- 返佣费用
  alter table FormCDB add FYfeiyong [decimal](18, 2) NULL;
  -- 是否缴纳保证金
 alter table FormCDB add JLbaozhengjin varchar(100)  null;
  -- 保证金金额
  alter table FormCDB add BZJjine [decimal](18, 2) NULL;
  -- 总标的金额
  alter table FormCDB add ZBjine [decimal](18, 2) NULL;
  -- 总标的比例
  alter table FormCDB add ZBbili [decimal](18, 2) NULL;
  -- 富昌实收费用
  alter table FormCDB add FCSSfeiyong [decimal](18, 2) NULL;
  -- 富昌占总标的比例
  alter table FormCDB add FCZbili [decimal](18, 2) NULL;
  
  -- 他司实收费用（元）
  alter table FormCDB add TSSHfeiyong [decimal](18, 2) NULL;
    -- 收据/发票
  alter table FormCDB add shouju varchar(100)  null;
  -- 税费（元）
  alter table FormCDB add suifei [decimal](18, 2) NULL;


  -- 修改字段长度

alter table [dbo].[FormCDB] alter column [FormTitle] text NULL; 

alter table [dbo].[FormCDB] alter column 	[ArbitrationNumber] text NULL; 
alter table [dbo].[FormCDB] alter column 	[ApplyUser] text NULL; 
alter table [dbo].[FormCDB] alter column 	[Respondent] text NULL; 
alter table [dbo].[FormCDB] alter column 	[ApplyGuarantee] text NULL; 
alter table [dbo].[FormCDB] alter column 	[GuaranteeSituation] text NULL; 
alter table [dbo].[FormCDB] alter column 	[ApplyIDCard] text NULL; 
alter table [dbo].[FormCDB] alter column 	[ApplyAddress] text NULL; 
alter table [dbo].[FormCDB] alter column 	[CauseOfAction] text NULL; 
alter table [dbo].[FormCDB] alter column 	[CompanyGuarantee] text NULL; 
alter table [dbo].[FormCDB] alter column 	[CompanyUser] text NULL; 
alter table [dbo].[FormCDB] alter column 	[CompanyAddress] text NULL; 

alter table [dbo].[FormCDB] alter column 	[CompanyTel] text NULL; 
alter table [dbo].[FormCDB] alter column 	[InsuranceCooperation] text NULL; 
alter table [dbo].[FormCDB] alter column 	[BusinessRemark] text NULL; 
alter table [dbo].[FormCDB] alter column 	[ReceiptInfo] text NULL; 
alter table [dbo].[FormCDB] alter column 	[FinanceRemark] text NULL; 
alter table [dbo].[FormCDB] alter column 	[Judge] text NULL; 


alter table [dbo].[FormCDB] alter column 	[DataSend] text NULL; 
alter table [dbo].[FormCDB] alter column 	[Quota] text NULL; 
alter table [dbo].[FormCDB] alter column 	[GeneralRemark] text NULL; 
alter table [dbo].[FormCDB] alter column 	[PropertyClues] text NULL; 
alter table [dbo].[FormCDB] alter column 	[AccountRemark] text NULL; 
alter table [dbo].[FormCDB] alter column 	[CompanyName] text NULL; 

alter table [dbo].[FormCDB] alter column 	[AccountNo] text NULL; 
alter table [dbo].[FormCDB] alter column 	[ContactName] text NULL; 
alter table [dbo].[FormCDB] alter column 	[ContactTpey] text NULL; 
alter table [dbo].[FormCDB] alter column 	[Remark] text NULL; 
alter table [dbo].[FormCDB] alter column 	[SealStatus] text NULL; 
alter table [dbo].[FormCDB] alter column 	[LBgongsi] text NULL; 
alter table [dbo].[FormCDB] alter column 	[JLbaozhengjin] text NULL; 
alter table [dbo].[FormCDB] alter column 	[shouju] text NULL; 

-- chenxianglin 2017年12月17日22:29:29 添加联保编号
alter table FormCDB add LianBaoBianhao varchar(500)  null;